class Solution:
    def StrToInt(self, s):
        pass

def str2Int(s):
    value = 0
    is_minus = False
    for char,pos in zip(s,range(len(s))):
        if pos==0 and char == '+':
            is_minus = False
            continue
        if pos==0 and char == '-':
            is_minus = True
            continue
        if ord(char) < ord('0') or ord(char) > ord('9'):
            return 0
        else:
            value += (ord(char)-ord('0'))*(10**(len(s)-pos-1))
    return (-value) if is_minus else value

print(str2Int('-1234'))